/**
  学生信息管理详情页-学籍信息、教育背景、工作经历、联合培养、证件信息、联系人、宿舍、其他
*/
<template>
    <div class="common-info-new-container">
        <div class="change-tip" v-if="hasChecked">
            (标
            <span class="color-block"></span>
            色字段为正在变更中...)
        </div>
        <div v-if="finished">
            <div style="text-align: right;" v-if="globalEdit || superLimitNotStu">
                <el-button type="primary" style="margin-bottom: 10px;" @click="saveData()">{{ $t('student.save') }}</el-button>
            </div>
            <div class="common-info-new-content" v-for="(item, index) in commonInfo" :key="index">
                <el-form :model="item.formInfo" :ref="'formInfo' + index" class="common-info-form">
                    <table>
                        <tbody>
                            <tr>
                                <td colspan="6" style="padding: 7px;">
                                    <span>{{ item.title }}</span>
                                    <el-button v-if="isMulti && (globalEdit || superLimitNotStu)" class="common-info-delete-btn" type="text" @click="deleteTable(index, item.id)">{{ $t('student.delete') }}</el-button>
                                </td>
                            </tr>
                            <tr v-for="(subItem, subIndex) in item.tableData" :key="subIndex">
                                <td :class="subItem.b.inReview ? ['field-checked', 'common-info-td-title'] : 'common-info-td-title'" v-if="subItem.a">
                                    <font class="is-require" v-if="(subItem.b.isRequire || subItem.b.fieldId === 69) && ((globalEdit && subItem.b.isEdit) || superLimitNotStu)">*</font>
                                    <span>{{ subItem.a }}</span>
                                </td>
                                <td :class="subItem.b.inReview ? ['field-checked', 'common-info-td-content'] : 'common-info-td-content'" v-if="subItem.b">
                                    <span v-if="(globalEdit && subItem.b.isEdit) || superLimitNotStu">
                                        <el-form-item :prop="'ID-' + subItem.b.fieldId + '-' + subItem.b.column" :rules="[{validator: validator, trigger: subItem.b.type === 'select' ? 'change' : 'blur'}]">
                                            <edit-dom-info 
                                                :fieldInfo="item.formInfo['ID-' + subItem.b.fieldId + '-' + subItem.b.column]" 
                                                :options="options[subItem.b.value]"
                                                :citys="citys"
                                                :XJZYOptions="XJZYOptions"
                                                :ZYFXMCOptions="ZYFXMCOptions"
                                                :index="index"
                                                :unionCollegeData="unionCollegeData"
                                                @change-current-grade="changeCurrentGrade"
                                                @change-pager-select="changePagerSelect"
                                                @change-normal-select="changeNormalSelect"
                                                @change-choose-type="changeChooseType">
                                            </edit-dom-info>
                                        </el-form-item>
                                    </span>
                                    <span v-else>
                                        <span v-if="subItem.b.type === 'image'">
                                            <div class="image-container">
                                                <div v-for="item in subItem.b.fileList" :key="item.objectKey">
                                                    <img :src="item.url" alt="" />
                                                    <span>
                                                        <i class="el-icon-zoom-in" @click="selectPicture(item)"></i>
                                                    </span>
                                                </div>
                                            </div>
                                        </span>
                                        <span v-else>{{ getValue(subItem.b) }}</span>
                                    </span>
                                </td>
                                <td :class="subItem.d.inReview ? ['field-checked', 'common-info-td-title'] : 'common-info-td-title'" v-if="subItem.c">
                                    <font class="is-require" v-if="(subItem.d.isRequire || subItem.d.fieldId === 69) && ((globalEdit && subItem.d.isEdit) || superLimitNotStu)">*</font>
                                    <span>{{ subItem.c }}</span>
                                </td>
                                <td :class="subItem.d.inReview ? ['field-checked', 'common-info-td-content'] : 'common-info-td-content'" v-if="subItem.d">
                                    <span v-if="(globalEdit && subItem.d.isEdit) || superLimitNotStu">
                                        <el-form-item :prop="'ID-' + subItem.d.fieldId + '-' + subItem.d.column" :rules="[{validator: validator, trigger: subItem.d.type === 'select' ? 'change' : 'blur'}]">
                                            <edit-dom-info 
                                                :fieldInfo="item.formInfo['ID-' + subItem.d.fieldId + '-' + subItem.d.column]" 
                                                :options="options[subItem.d.value]"
                                                :citys="citys"
                                                :XJZYOptions="XJZYOptions"
                                                :ZYFXMCOptions="ZYFXMCOptions"
                                                :index="index"
                                                :unionCollegeData="unionCollegeData"
                                                @change-current-grade="changeCurrentGrade"
                                                @change-pager-select="changePagerSelect"
                                                @change-normal-select="changeNormalSelect">
                                            </edit-dom-info>
                                        </el-form-item>
                                    </span>
                                    <span v-else>
                                        <span v-if="subItem.d.type === 'image'">
                                            <div class="image-container">
                                                <div v-for="item in subItem.d.fileList" :key="item.objectKey">
                                                    <img :src="item.url" alt="" />
                                                    <span>
                                                        <i class="el-icon-zoom-in" @click="selectPicture(item)"></i>
                                                    </span>
                                                </div>
                                            </div>
                                        </span>
                                        <span v-else>{{ getValue(subItem.d) }}</span>
                                    </span>
                                </td>
                                <td :class="subItem.f.inReview ? ['field-checked', 'common-info-td-title'] : 'common-info-td-title'" v-if="subItem.e">
                                    <font class="is-require" v-if="(subItem.f.isRequire || subItem.f.fieldId === 69) && ((globalEdit && subItem.f.isEdit) || superLimitNotStu)">*</font>
                                    <span>{{ subItem.e }}</span>
                                </td>
                                <td :class="subItem.f.inReview ? ['field-checked', 'common-info-td-content'] : 'common-info-td-content'" v-if="subItem.f">
                                    <span v-if="(globalEdit && subItem.f.isEdit) || superLimitNotStu">
                                        <el-form-item :prop="'ID-' + subItem.f.fieldId + '-' + subItem.f.column" :rules="[{validator: validator, trigger: subItem.f.type === 'select' ? 'change' : 'blur'}]">
                                            <edit-dom-info 
                                                :fieldInfo="item.formInfo['ID-' + subItem.f.fieldId + '-' + subItem.f.column]" 
                                                :options="options[subItem.f.value]"
                                                :citys="citys"
                                                :XJZYOptions="XJZYOptions"
                                                :ZYFXMCOptions="ZYFXMCOptions"
                                                :index="index"
                                                :unionCollegeData="unionCollegeData"
                                                @change-current-grade="changeCurrentGrade"
                                                @change-pager-select="changePagerSelect"
                                                @change-normal-select="changeNormalSelect">
                                            </edit-dom-info>
                                        </el-form-item>
                                    </span>
                                    <span v-else>
                                        <span v-if="subItem.f.type === 'image'">
                                            <div class="image-container">
                                                <div v-for="item in subItem.f.fileList" :key="item.objectKey">
                                                    <img :src="item.url" alt="" />
                                                    <span>
                                                        <i class="el-icon-zoom-in" @click="selectPicture(item)"></i>
                                                    </span>
                                                </div>
                                            </div>
                                        </span>
                                        <span v-else>{{ getValue(subItem.f) }}</span>
                                    </span>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </el-form>
            </div>
            <div class="add-btn-container" v-if="(globalEdit || superLimitNotStu) && isMulti" @click="addForm">
                <span>+</span>
                <span>{{ $t('student.add') }}{{ title }}</span>
            </div>
        </div>
        <difference-dialog
            ref="diffDialog"
            :post-data="postData.stuDetailInfoList"
            :raw-data="dataSource"
            :options="options"
            :XJZYOptions="XJZYOptions"
            :ZYFXMCOptions="ZYFXMCOptions"
            :checked="checked"
            @save-diff="hasCheckFieldSubmit"
            @update="getStuDetail"
            :city="[]"
            :label="title"
            :isMulti="isMulti"
        ></difference-dialog>
        <el-dialog title="预览" ref="previewDialog" class="preview-dialog" :visible.sync="dialogVisible">
          <img v-if="dialogVisible" :src="currentImgSrc" width="100%">
        </el-dialog>
    </div>
</template>
<script>
import moment from 'moment'
import differenceDialog from "./differenceDialog"
import { submitField, getCitys, getCityNameByValue } from './businessMethods'
import { queryDic } from 'common/src/api/dictionary'
import editDomInfo from './editDomInfo'
import {
    getStudentDetail,
    stuDetailSubmit,
    findStatusProfessionList,
    // getDirections,
    findStuDicLinkage,
    // getMajorDirectionNames,
    getSetMajorDirectionNames
} from 'common/src/api/studentinfo'
import { getImageData, universities, getCollegeListByNationCode } from 'common/src/api/teacherinfo'
// import REST from './test' 
const ADD_FORM = "0"
const FORM_TYPE = {
    ADD: 1,
    EDIT: 2,
    DELETE: 3
}
export default {
    name: "commonInfoNew",
    props: ["uid", "tableInfo", "title", "isDelete", "isMulti", "superLimit", "isStudent", "tabValue"],
    components: {
        editDomInfo,
        differenceDialog
    },
    data() {
        return {
            globalEdit: true,
            superLimitNotStu: false,
            count: 0,
            userInfo: {},
            // 原始数据
            dataSource: [],
            commonInfo: [],
            commonInfoCopy: [],
            options: {},
            citys: [],
            XJZYOptions: [],
            ZYFXMCOptions: [],
            // 对方院校,院所
            unionCollegeData: [],
            // 是否有审核字段,控制样式标色字段的提示
            hasChecked: false,
            finished: false,
            // 可搜索集合
            searchColumns: [
                62, // 学院
                68, // 学籍专业
                69, // 培养专业
                67, // 招生专业
                98, // 门类
                146, // 学位专业
                233, // 博士学位专业
                219, // 硕士学位专业
                235, // 博士学位单位
                221, // 硕士学位单位
                148, // 学位单位
                228, // 硕士门类
                155, // 门类
                242, // 博士门类
                177, // 民族
                108, // 合作学校
                166 // 对方院校、院所
            ],
            // 专业集合
            profession: [
                67, // 招生专业
                69 // 培养专业
            ],
            // 学籍存在联动的集合
            stuStatusRelationsArray: [
                "DEGREE_TYPE_", // 学位类型
                "TRAINING_LEVEL_" // 培养层次
            ],
            // 培养层次改变，重新关联的字段
            trainingLevelRelation: [
                "X_RXFS", // 入学方式ID-80-ENROL_METHODS_
                "X_ZXJH", // 专项计划ID-84-SPCIAL_PLAN_
                "X_XWLB", // 学位上报类别ID-97-DEGREE_CATEGORY_
                "G_ML", // 门类ID-98-CATEGORY_(学籍信息);门类ID-155-CATEGORY_CODE_(教育背景);硕士门类ID-228-CATEGORY_CODE_(教育背景)博士门类ID-242-CATEGORY_CODE_(教育背景)
                "G_XWDM", // 学位ID-99-DEGREE_CODE_(学籍信息);学位ID-154-DEGREE_CODE_(教育背景);硕士学位ID-227-DEGREE_CODE_(教育背景)博士学位ID-241-DEGREE_CODE_(教育背景)
                "education" // 学历ID-152-EDUCATION_NAME_(教育背景);硕士学历ID-225-EDUCATION_NAME_(教育背景);博士学历ID-239-EDUCATION_NAME_(教育背景)
            ],
            // 学位类型改变，重新关联的字段
            degreeTypeRelation: [
                "X_RXFS", // 入学方式ID-80-ENROL_METHODS_
                "G_ML" // 门类ID-98-CATEGORY_(学籍信息);门类ID-155-CATEGORY_CODE_(教育背景);硕士门类ID-228-CATEGORY_CODE_(教育背景)博士门类ID-242-CATEGORY_CODE_(教育背景)
            ],
            formInfo: {},
            // 是否存在审核,控制显示差异弹框
            checked: false,
            // 最终的数据
            postData: {
                studentId: '',
                stuDetailInfoList: []
            },
            // 删除数据库的传参保留
            deleteStuDetailInfoList: [],
            currentImgSrc: '',
            dialogVisible: false,
            // 当前年级
            currentGrade: '',
            // 学籍学院
            universityCollege: '',
            // 学院
            currentCollege: '',
            // 学位类型
            degreeType: '',
            // 培养专业
            cultivateProfessional: '',
            // 培养层次
            trainingLevel: '',
            // 教育背景学位专业
            degreeProfession: null
        };
    },
    mounted() {
        this.postData.studentId = this.uid
        // 获取当前用户信息
        if (localStorage.getItem('sessiondata')) {
            if (JSON.parse(localStorage.getItem('sessiondata')).mockUser) {
                this.userInfo = JSON.parse(localStorage.getItem('sessiondata')).mockUser
            } else {
                this.userInfo = JSON.parse(localStorage.getItem('user'))
            }
        }
        this.getStuDetail()
    },
    methods: {
        // 字符校验
        validator(rule, value, callback) {
            // 必填性校验
            if (value.isRequire && !value.columnValue) {
                return callback(new Error(value.nameZH + '不能为空'))
            } else if (value.isRequire && Array.isArray(value.columnValue) && value.columnValue.length === 0) {
                return callback(new Error(value.nameZH + '不能为空'))
            } else if (value.fieldId === 69 && !value.columnValue) {
                return callback(new Error(value.nameZH + '不能为空'))
            } else if (value.columnValue && value.fieldId === 169 && this.commonInfo[value.currentIndex].formInfo['ID-168-TYPE_'].columnValue !== '01') {
                return callback()
            } else if (value.columnValue && value.legalityCheck && !new RegExp(value.legalityCheck).test(value.columnValue)) { // 正则校验
                return callback(new Error(value.errorMessage || '输入的格式有误'))
            } else if (value.fieldId == 136) { // 最长学习年限 是0.5的整数倍
                if(!value.columnValue){
                    return callback(new Error(value.nameZH + '不能为空'))
                }
                if(value.columnValue > 10){
                    return callback(new Error(value.nameZH + '不能超过10年'))
                }

                let multipleNum = 1000000//扩大倍数
                if((value.columnValue*multipleNum) % (0.5*multipleNum) / multipleNum != 0 || value.columnValue == 0){//不能为0 且输入内容必须是0.5的整数倍
                    return callback(new Error('请输入有效数字'))
                }

                return callback()
            } else if (value.columnValue && value.dataType === 'float' && isNaN(value.columnValue)) { // 浮点数校验
                callback(new Error('请输入有效数字'))
            } else if (value.columnValue && value.dataType === 'long' && value.type !== 'date' && !/^\d+$/.test(value.columnValue)) { // 长型校验
                callback(new Error('请输入有效整数'))
            } else if (value.columnValue && value.dataType === 'int' && value.type !== 'date' && !/^\d+$/.test(value.columnValue)) { // 整型校验
                callback(new Error('请输入有效整数'))
            } else {
                return callback()
            }
        },
        // 根据表名和学生ID查询详情信息
        async getStuDetail() {
            let _this = this
            // 当前年级
            this.currentGrade = ''
            // 学籍学院
            this.universityCollege = ''
            // 学院
            this.currentCollege = ''
            // 学位类型
            this.degreeType = ''
            // 培养层次
            this.trainingLevel = ''
            // 获取数据之前清空学籍专业的列表
            _this.XJZYOptions = []
            const stuResp = await getStudentDetail({
                studentId: this.uid,
                fieldClasses: this.tableInfo.map(value => {
                    return value.tableName
                })
            })
            // const stuResp = REST
            if (stuResp.code == 200 && stuResp.data && stuResp.data.length > 0) {
                // 备份原始数据
                this.dataSource = _.cloneDeep(stuResp.data)
                let currentCommonInfo = _.cloneDeep(stuResp.data)
                currentCommonInfo.map((value, valueIndex) => {
                    // 赋值当前title和tableName
                    if (value.stuAttriInfos && Array.isArray(value.stuAttriInfos) && value.stuAttriInfos.length > 0) {
                        let currentTableInfo = _this.tableInfo.find(tableItem => {
                            return tableItem.tableName === value.stuAttriInfos[0].from
                        })
                        if (currentTableInfo) {
                            value['title'] = currentTableInfo.title
                            value['tableName'] = currentTableInfo.tableName
                        }
                    }
                    value['formInfo'] = {}
                    value['originData'] = []
                    value['tableData'] = []
                    // 处理数据
                    if (value.stuAttriInfos && Array.isArray(value.stuAttriInfos) && value.stuAttriInfos.length > 0) {
                        value.stuAttriInfos.map((item, index) => {
                            // 初始值columnValue拷贝
                            item['oldRecord'] = item.columnValue
                            // 处理字典数组
                            if (item.type === 'select' && item.value && !Object.keys(this.options).includes(item.value)) {
                                this.options[item.value] = []
                            }
                            // 证件信息-证件照片
                            if (item.fieldId === 172 && item.column === 'FILE_' && item.columnValue) {
                                _this.getFilesList(item)
                            }
                            // 有字段状态处于审核中,控制样式标色字段的提示
                            if (item.inReview) {
                                this.hasChecked = true
                            }
                            // 院审或者校审字段返回为真,即>0,说明存在字段需要审核
                            if (item.isCollegeCheck || item.isSchoolCheck) {
                                this.checked = true
                            }
                            // 处理是否跨学科
                            if (item.fieldId === 90 && item.columnValue) {
                                item.columnValue = item.columnValue === 'MQ==' ? '1' : (item.columnValue === 'MA==' ? '0' : item.columnValue)
                            }
                            // 处理年份
                            if (item.type === "year" && item.columnValue) {
                                item.columnValue = item.columnValue.toString()
                            }
                            // 处理注册状态
                            if (item.fieldId === 100 && (item.columnValue !== null || item.columnValue !== '')) {
                                item.columnValue = item.columnValue.toString()
                            }
                            // 处理护照有校日期止ID-200-PASSPORT_EXPIRE_
                            if (item.fieldId === 200 && item.columnValue) {
                                item.columnValue = moment(item.columnValue).format("YYYY-MM-DD")
                            }
                            // 处理性别
                            if (item.fieldId === 175 && item.columnValue) {
                                item.columnValue = String(item.columnValue)
                            }
                            // 处理支持可搜索的下拉框
                            if (item.type === 'select' && this.searchColumns.includes(item.fieldId)) {
                                item.isSearch = true
                            }
                            // 当前年级赋值
                            if (item.fieldId === 76 && item.columnValue) {
                                this.currentGrade = item.columnValue
                            }
                            // 学籍学院赋值
                            if (item.fieldId === 248 && item.columnValue) {
                                this.universityCollege = item.columnValue
                            }
                            // 学院赋值
                            if (item.fieldId === 62 && item.columnValue) {
                                this.currentCollege = item.columnValue
                            }
                            // 学位类型赋值
                            if (item.fieldId === 96 && item.columnValue) {
                                this.degreeType = item.columnValue
                            }
                            // 培养专业赋值
                            if (item.fieldId === 69 && item.columnValue) {
                                this.cultivateProfessional = item.columnValue
                            }
                            // 培养层次赋值
                            if (item.fieldId === 72 && item.columnValue) {
                                this.trainingLevel = item.columnValue
                            }
                            // 备份原始数据
                            item['originValue'] = item.columnValue
                            // 记录可编辑字段的数量
                            if (this.isStudent && item.isEdit > 0) {
                                _this.count++
                            }
                            // 写入字段
                            // 研究生不显示学籍学院
                            if (!(this.userInfo.currentManageDptId && this.userInfo.currentManageDptId !== '1' && item.fieldId === 248)) {
                                item['currentIndex'] = valueIndex
                                value.formInfo['ID-' + item.fieldId + '-' + item.column] = item
                                value.originData.push(item)
                            }
                        })
                    }
                })
                // 记录可编辑字段的个数，若可编辑字段的个数===0，则此处不可编辑，保存/删除/新增按钮不显示
                if (this.superLimit) {
                    if (this.isStudent) {
                        if (this.count === 0) {
                            this.globalEdit = false
                        }
                    } else {
                        this.superLimitNotStu = true
                    }
                } else {
                    this.globalEdit = false
                }
                await this.getDictionaryData()
                currentCommonInfo.map((tableInfo, tableIndex) => {
                    // 学籍信息表中关于学籍专业需做以下处理
                    if (tableInfo.tableName === 'student_status_information_t') {
                        tableInfo.originData.map(item => {
                            // 培养专业
                            if (item.fieldId === 69) {
                                // 学院无专业，要清空专业的值，本科生+研究生：针对培养专业
                                if (_this.options['G_ZY'].length === 0) {
                                    tableInfo.formInfo['ID-69-CULTURE_PROFESSION_'].columnValue = null
                                    tableInfo.formInfo['ID-69-CULTURE_PROFESSION_']['originValue'] = null
                                } else { // 学院有专业，而培养专业返回为中文，则回显时需要转码，若不为中文则填入code值
                                    // tableInfo.formInfo['ID-69-CULTURE_PROFESSION_'].columnValue = _this.getValueByLabel(_this.options['G_ZY'], tableInfo.formInfo['ID-69-CULTURE_PROFESSION_'].columnValue)
                                    tableInfo.formInfo['ID-69-CULTURE_PROFESSION_']['originValue'] = tableInfo.formInfo['ID-69-CULTURE_PROFESSION_'].columnValue
                                }
                            }
                            // 学籍专业，研究生学籍专业与学院相关
                            if (item.fieldId === 68) {
                                // 本科生:若当前年级以及学籍学院都有值,调用接口获取学籍专业的数据
                                if (this.userInfo.currentManageDptId === '1' || !this.userInfo.currentManageDptId) {
                                    _this.getStuStatusProfession(_this.currentGrade, _this.universityCollege, item.columnValue).then(code => {
                                        if (code) {
                                            tableInfo.formInfo['ID-68-STATUS_PROFESSION_'].columnValue = code
                                            tableInfo.formInfo['ID-68-STATUS_PROFESSION_']['originValue'] = code
                                        }
                                    })
                                } else if (this.userInfo.currentManageDptId !== '1' && this.userInfo.currentManageDptId) { // 研究生
                                    // 研究生的学籍专业ID-68-STATUS_PROFESSION_与年级无关,与学院有关
                                    _this.getStuStatusProfession('', _this.currentCollege, item.columnValue).then(code => {
                                        if (code) {
                                            tableInfo.formInfo['ID-68-STATUS_PROFESSION_'].columnValue = code
                                            tableInfo.formInfo['ID-68-STATUS_PROFESSION_']['originValue'] = code
                                        }
                                    })
                                }
                            }
                            // 专业方向名称，获取专业方向名称的下拉框数据
                            if (item.fieldId === 70 && tableInfo.formInfo['ID-69-CULTURE_PROFESSION_']) {
                                // 传参为培养专业
                                _this.getProfessDirectNames(tableInfo.formInfo['ID-69-CULTURE_PROFESSION_'].columnValue)
                            }
                        })
                    }
                    // 教育背景模块，学位专业、硕士学位专业、博士学位专业处理，需求：若在字典中未匹配到则回显中文填入name，若匹配到则填入code
                    if (tableInfo.tableName === 'student_educational_backgroud_t') {
                        tableInfo.originData.map(item => {
                            // 学位专业、硕士学位专业、博士学位专业
                            if (item.column === 'MAJOR_CODE_') {
                                // 获取所在值的唯一性id
                                let key = 'ID-' + item.fieldId + '-' + item.column
                                tableInfo.formInfo[key].chooseType = 'input'
                                tableInfo.formInfo[key].columnValue = tableInfo.formInfo['ID-' + item.fieldId + '-' + 'MAJOR_NAME_'].columnValue
                                tableInfo.formInfo[key]['originValue'] = tableInfo.formInfo[key].columnValue
                            }
                        })
                    }
                    // 联合培养模块,对方院校,院所下拉框逻辑处理
                    if (tableInfo.tableName === 'student_joint_training_t') {
                        tableInfo.originData.map(item => {
                            let originCollegeCountry = ''
                            // 获取原就读院校所属国家的值
                            if (item.fieldId === 247) {
                                originCollegeCountry = item.columnValue
                            }
                            // 当前字段为对方院校,院所,由于原就读院校所属国家顺序在其字段之前,故传参已知其是否有值
                            if (item.fieldId === 166) {
                                this.getUnionCollegeByNation(originCollegeCountry)
                            }
                        })
                    }
                })
                // console.log(currentCommonInfo)
                // 写入字段
                this.commonInfo = currentCommonInfo
                // 表格布局处理数据
                this.finished = false
                this.commonInfo.forEach((tableInfo, index) => {
                    if (tableInfo.originData.length > 0) {
                        // 表格布局开始
                        for (let i = 0; i < tableInfo.originData.length; i += 3) {
                            if (!tableInfo.originData[i].inHide) {
                                let currentTr = {
                                    a: tableInfo.originData[i].nameZH,
                                    b: tableInfo.originData[i]
                                }
                                if (tableInfo.originData[i + 1] && !tableInfo.originData[i + 1].inHide) {
                                    currentTr['c'] = tableInfo.originData[i + 1].nameZH
                                    currentTr['d'] = tableInfo.originData[i + 1]
                                }
                                if (tableInfo.originData[i + 2] && !tableInfo.originData[i + 2].inHide) {
                                    currentTr['e'] = tableInfo.originData[i + 2].nameZH
                                    currentTr['f'] = tableInfo.originData[i + 2]
                                }
                                tableInfo.tableData.push(currentTr)
                            }
                        }
                        // 表格布局结束
                    }
                })
                // 作为新增表单的拷贝原始数据
                this.commonInfoCopy = _.cloneDeep(this.commonInfo)
                this.finished = true
            }
        },
        // 检查是否有改动
        checkIsDiff() {
            let hasDiff = false
            this.commonInfo.forEach(value => {
                for (let key in value.formInfo) {
                    if (value.formInfo[key].originValue != value.formInfo[key].columnValue) {
                        hasDiff = true
                    }
                }
            })
            return hasDiff
        },
        // 查看图片
        selectPicture(picItem) {
            this.dialogVisible = true
            this.currentImgSrc = picItem.url
        },
        // 获取文件列表
        async getFilesList(column) {
            let fileList = []
            let fileArr = column.columnValue ? column.columnValue.split(';') : []
            if (fileArr.length > 0) {
                fileArr.forEach(async value => {
                    let currentResp = await getImageData(value)
                    if (currentResp.code === 200 && currentResp.data) {
                        fileList.push({
                            url: currentResp.data.base,
                            objectkey: value
                        })
                    }
                })
            }
            column.fileList = fileList
        },
        // 获取专业方向名称，传参为培养专业的值
        // 变更：获取专业方向名称，传参变更为年级，学院，专业
        async getProfessDirectNames(val) {
            let _this = this
            _this.ZYFXMCOptions = []
            if (val) {
                // const directionNameRes = await getMajorDirectionNames(val)
                getSetMajorDirectionNames({
                    grade: this.currentGrade,
                    pageNum_: 1,
                    pageSize_: 999999,
                    professionCode: val
                }).then(directionNameRes => {
                    if (directionNameRes.code === 200 && Array.isArray(directionNameRes.data.list) && directionNameRes.data.list.length > 0) {
                        _this.ZYFXMCOptions = directionNameRes.data.list.map(value => {
                            return {
                                label: this.$store.getters.language === 'en' ? value.nameEn : value.name,
                                value: value.code
                            }
                        })
                    }
                    // if (directionNameRes.code === 200) {
                    //     let key = 'X_FX'
                    //     let opts = Object.keys(directionNameRes.data[key]).map(i => ({
                    //         value: i,
                    //         label: directionNameRes.data[key][i]
                    //     }))
                    //     if (Array.isArray(opts) && opts.length > 0) {
                    //         _this.ZYFXMCOptions = opts
                    //     }
                    // }
                })
            }
            // 原始逻辑，待确认
            // await getDirections(this.uid).then(async res => {
            //     if (res.code === 200 && res.data) {
            //         let directions = []
            //         for (let key in res.data) {
            //             directions.push({
            //                 label: res.data[key],
            //                 value: key
            //             })
            //         }
            //         _this.ZYFXMCOptions = directions
            //     } else if (val) {
            //         await getMajorDirectionNames(val).then(res => {
            //             let key = 'X_FX'
            //             let opts = Object.keys(res.data[key]).map(i => ({
            //                 value: i,
            //                 label: res.data[key][i]
            //             }))
            //             if (Array.isArray(opts) && opts.length > 0) {
            //                 _this.ZYFXMCOptions = opts
            //             }
            //         })
            //     }
            // })
        },
        // 获取学籍专业
        async getStuStatusProfession(currentGrade, college, columnValue) {
            let _this = this
            _this.XJZYOptions = []
            const professionRes = await findStatusProfessionList({
                grade: currentGrade,
                statusFacultyList: [college]
            })
            if (professionRes && professionRes.code === 200 && Array.isArray(professionRes.data) && professionRes.data.length > 0) {
                professionRes.data.forEach(val => {
                    _this.XJZYOptions.push({
                        label: val.professionName + '(' + val.professionCode + ')',
                        value: val.statusProfessionCode
                    })
                })
                if (columnValue) {
                    // 获取到下拉框数据后重新赋值,当返回值为中文名称
                    let currentNameOption = professionRes.data.find(option => {
                        return option.professionName === columnValue
                    })
                    // 当返回值为中文且能匹配上
                    if (currentNameOption && currentNameOption.statusProfessionCode) {
                        return currentNameOption.statusProfessionCode
                    }
                }
            }
        },
        // 修改pagerSelect的值
        async changePagerSelect(val) {
            // 返回了当前字段的fieldInfo，当前修改的值val，以及当前的表单所在commonInfo的索引
            let currentInfo = _.cloneDeep(val)
            // 当前修改了学籍学院
            if (currentInfo.fieldInfo.fieldId === 248) {
                // 学籍学院值修改后需清空学籍专业ID-68-STATUS_PROFESSION_，同时重新获取学籍专业ID-68-STATUS_PROFESSION_的下拉框数据
                if (this.commonInfo[currentInfo.index].formInfo['ID-68-STATUS_PROFESSION_']) {
                    this.commonInfo[currentInfo.index].formInfo['ID-68-STATUS_PROFESSION_'].columnValue = null
                }
                // 记录当前学籍学院的值
                this.universityCollege = currentInfo.val
                // 记录当前年级的值
                if (this.commonInfo[currentInfo.index].formInfo['ID-76-CURRENT_GRADE_']) {
                    this.currentGrade = this.commonInfo[currentInfo.index].formInfo['ID-76-CURRENT_GRADE_'].columnValue
                }
                // 存在学籍专业
                if (this.commonInfo[currentInfo.index].formInfo['ID-68-STATUS_PROFESSION_']) {
                    // 重新获取学籍专业下拉框的数据
                    this.getStuStatusProfession(this.currentGrade, this.universityCollege)
                }
            } else if (currentInfo.fieldInfo.value === 'X_YX' && currentInfo.fieldInfo.fieldId !== 248) { // 修改了管理院系(ID-113-DEPARTMENT_)或者学院(ID-62-FACULTY_)
                // 记录当前学院的值
                this.currentCollege = currentInfo.val
                // 再次请求字典接口，因为学院为其中的一个筛选项
                await this.getDictionaryData()
                // 清空培养专业的值
                this.commonInfo[currentInfo.index].formInfo['ID-69-CULTURE_PROFESSION_'].columnValue = null
                // 研究生，修改了学院，需要清空学籍专业的值
                if (this.userInfo.currentManageDptId !== '1' && this.userInfo.currentManageDptId && currentInfo.fieldInfo.fieldId === 62) {
                    // 清空学籍专业ID-68-STATUS_PROFESSION_
                    if (this.commonInfo[currentInfo.index].formInfo['ID-68-STATUS_PROFESSION_']) {
                        this.commonInfo[currentInfo.index].formInfo['ID-68-STATUS_PROFESSION_'].columnValue = null
                        // 重新获取学籍专业下拉框的数据
                        this.getStuStatusProfession('', this.currentCollege)
                    }
                }
                // 同时清空专业方向的值以及下拉框数据
                this.commonInfo[currentInfo.index].formInfo['ID-70-MAJOR_DIRECTION_CODE_'].columnValue = null
                this.ZYFXMCOptions = []
            } else if (currentInfo.fieldInfo.value === 'G_ZY' && currentInfo.val && this.commonInfo[currentInfo.index].formInfo['ID-70-MAJOR_DIRECTION_CODE_']) { // 修改了培养专业ID-69-CULTURE_PROFESSION_（招生专业ID-67-PROFESSION_不可修改）,值不为空，存在专业方向中文名称字段
                // 修改了培养专业，需清空专业方向名称ID-70-MAJOR_DIRECTION_CODE_的值，并且重新获取专业方向名称ID-70-MAJOR_DIRECTION_CODE_下拉框的数据
                this.commonInfo[currentInfo.index].formInfo['ID-70-MAJOR_DIRECTION_CODE_'].columnValue = null
                this.getProfessDirectNames(currentInfo.val)
            } else if (currentInfo.fieldInfo.value === 'G_GJQU' && currentInfo.fieldInfo.fieldId === 247 && this.commonInfo[currentInfo.index].formInfo['ID-166-UNION_COLLEGE_']) { // 联合培养，修改了原就读院校所属国家ID-247-ORIGINAL_COLLEGE_COUNTRY_
                // 清空对方院校、院所ID-166-UNION_COLLEGE_的值
                this.commonInfo[currentInfo.index].formInfo['ID-166-UNION_COLLEGE_'].columnValue = null
                // 重新获取对方院校、院所的下拉框数据
                this.getUnionCollegeByNation(currentInfo.val)
            }
        },
        // 获取关联字典接口
        getLinkDictionary(relationParams) {
            let _this = this
            findStuDicLinkage(relationParams).then(res => {
                if (res.code == 200) {
                    let options = {}
                    for (let key in res.data) {
                        let option = []
                        for (let label in res.data[key]) {
                            option.push({
                                label: label,
                                value: res.data[key][label]
                            })
                        }
                        _this.$set(_this.options, key, option)
                    }
                }
            })
        },
        // 处理学籍信息下拉框的联动
        dealWithStuStatusLink(currentInfo) {
            // 修改了培养专业的值，需清空专业方向名称ID-70-MAJOR_DIRECTION_CODE_的值，并且重新获取专业方向名称ID-70-MAJOR_DIRECTION_CODE_下拉框的数据
            if (currentInfo.fieldInfo.fieldId === 69 && this.commonInfo[currentInfo.index].formInfo['ID-70-MAJOR_DIRECTION_CODE_']) {
                this.commonInfo[currentInfo.index].formInfo['ID-70-MAJOR_DIRECTION_CODE_'].columnValue = null
                this.getProfessDirectNames(currentInfo.val)
            } else if (this.stuStatusRelationsArray.includes(currentInfo.fieldInfo.column)) { // 修改了学位类型或者培养层次
                if (currentInfo.fieldInfo.fieldId === 72) {
                    // 记录培养层次的值
                    this.trainingLevel = currentInfo.val
                }
                if (currentInfo.fieldInfo.fieldId === 96) {
                    // 记录学位类型的值
                    this.degreeType = currentInfo.val
                }
                // 记录当前所对应联动字段的集合，若修改了学位类型则集合为degreeTypeRelation否则集合为trainingLevelRelation
                let relations = currentInfo.fieldInfo.column === "DEGREE_TYPE_" ? this.degreeTypeRelation : this.trainingLevelRelation
                // 若学籍信息中目前的培养层次的值为1 || 6（本科生 || 博士生），则入学方式不变，清空其余关联关系的值
                let currentTrainingLevel = null
                // 默认需清空入学方式
                let clearRXFX = true
                // 修改了学位类型ID-96-DEGREE_TYPE_(学籍信息)
                if (currentInfo.fieldInfo.column === 'DEGREE_TYPE_') {
                    // 若学籍信息中目前的培养层次的值为1 || 6（本科生 || 博士生），则入学方式不变，清空其余关联关系的值
                    for (let key in this.commonInfo[currentInfo.index].formInfo) {
                        // 培养层次
                        if (this.commonInfo[currentInfo.index].formInfo[key].column === 'TRAINING_LEVEL_') {
                            currentTrainingLevel = this.commonInfo[currentInfo.index].formInfo[key].columnValue
                        }
                    }
                    // 培养层次的值为1 || 6（本科生 || 博士生）
                    if (["1", "6"].includes(currentTrainingLevel)) {
                        // 无需清空
                        clearRXFX = false
                    }
                }
                let relationParams = {
                    // 学位类型
                    degreeTypeCode: '',
                    // 培养层次--学籍信息
                    trainingLevelCode: ''
                }
                // 需清空所有
                if (clearRXFX) {
                    relations.forEach(value => {
                        for (let key in this.commonInfo[currentInfo.index].formInfo) {
                            if (this.commonInfo[currentInfo.index].formInfo[key].column === "DEGREE_TYPE_") {
                                relationParams.degreeTypeCode = this.commonInfo[currentInfo.index].formInfo[key].columnValue
                            }
                            if (this.commonInfo[currentInfo.index].formInfo[key].column === "TRAINING_LEVEL_") {
                                relationParams.trainingLevelCode = this.commonInfo[currentInfo.index].formInfo[key].columnValue
                            }
                            if (this.commonInfo[currentInfo.index].formInfo[key].value === value) {
                                this.commonInfo[currentInfo.index].formInfo[key].columnValue = null
                            }
                        }
                    })
                } else { // 无需清空入学方式
                    relations.forEach(value => {
                        for (let key in this.commonInfo[currentInfo.index].formInfo) {
                            if (this.commonInfo[currentInfo.index].formInfo[key].column === "DEGREE_TYPE_") {
                                relationParams.degreeTypeCode = this.commonInfo[currentInfo.index].formInfo[key].columnValue
                            }
                            if (this.commonInfo[currentInfo.index].formInfo[key].column === "TRAINING_LEVEL_") {
                                relationParams.trainingLevelCode = this.commonInfo[currentInfo.index].formInfo[key].columnValue
                            }
                            if (key !== 'ID-80-ENROL_METHODS_' && this.commonInfo[currentInfo.index].formInfo[key].value === value) {
                                this.commonInfo[currentInfo.index].formInfo[key].columnValue = null
                            }
                        }
                    })
                }
                // 重新获取关联字典
                if (relationParams.degreeTypeCode || relationParams.trainingLevelCode) {
                    this.getLinkDictionary(relationParams)
                }
                // 研究生清空学籍专业和培养专业的值，更新下拉框数据
                if (this.userInfo.currentManageDptId !== '1') {
                    // 培养层次、学位类型的值修改后需清空学籍专业ID-68-STATUS_PROFESSION_，同时重新获取学籍专业ID-68-STATUS_PROFESSION_的下拉框数据
                    if (this.commonInfo[currentInfo.index].formInfo['ID-68-STATUS_PROFESSION_']) {
                        this.commonInfo[currentInfo.index].formInfo['ID-68-STATUS_PROFESSION_'].columnValue = null
                        // 重新获取学籍专业下拉框的数据
                        this.getStuStatusProfession('', this.currentCollege)
                    }
                    // 培养层次、学位类型的值修改后需清空培养专业ID-69-CULTURE_PROFESSION_，同时重新获取培养专业ID-69-CULTURE_PROFESSION_的下拉框数据
                    if (this.commonInfo[currentInfo.index].formInfo['ID-69-CULTURE_PROFESSION_']) {
                        this.commonInfo[currentInfo.index].formInfo['ID-69-CULTURE_PROFESSION_'].columnValue = null
                        this.getDictionaryData()
                    }
                }
            }
        },
        // 修改普通下拉框的值
        changeNormalSelect(val) {
            // 返回了当前字段的fieldInfo，当前修改的值val，以及当前的表单所在commonInfo的索引
            let currentInfo = _.cloneDeep(val)
            // 学籍信息
            if (currentInfo.fieldInfo.from === 'student_status_information_t') {
                // 处理学籍信息的联动
                this.dealWithStuStatusLink(currentInfo)
            }
        },
        // 修改教育背景--学位类型的选择
        changeChooseType(val) {
            // 返回了当前字段的fieldInfo，当前修改的值val，以及当前的表单所在commonInfo的索引
            let currentInfo = _.cloneDeep(val)
            this.commonInfo[currentInfo.index].formInfo['ID-' + currentInfo.fieldInfo.fieldId + '-' + currentInfo.fieldInfo.column].columnValue = null
        },
        // 根据原就读院校所属国家获取对方院校、院所
        async getUnionCollegeByNation(code) {
            // 初始化清空下拉框数据
            this.unionCollegeData = []
            if (this.userInfo && this.userInfo.currentManageDptId) {
                // 本科生
                if (this.userInfo.currentManageDptId === '1') {
                    await universities({ code: code }).then(res=> {
                        if(res.code === 200) {
                            res.data.forEach(val => {
                                this.unionCollegeData.push(
                                    {
                                        label: val.universityNameZN,
                                        value: val.universityCode
                                    }
                                )
                            })
                        }
                    })
                } else { // 研究生
                    await getCollegeListByNationCode({ code: code, collegeId: '' }).then(res=> {
                        if(res.code === 200) {
                            res.data.forEach(val => {
                                this.unionCollegeData.push(
                                    {
                                        label: val.collegeName,
                                        value: val.collegeCode
                                    }
                                )
                            })
                        }
                    })
                }
            }
        },
        // 获取字典
        async getDictionaryData() {
            let _this = this
            // 筛选条件字典查询
            let data = {
                lang: this.$store.getters.language || 'cn',
                type: 'allChild',
                keys: Object.keys(this.options),
                filter: {
                  facultys: [this.currentCollege],
                  grade: this.currentGrade,
                  degreeType: [this.degreeType]
                }
            }
            // 研究生需要传培养层次的筛选项
            if (this.userInfo.currentManageDptId !== '1') {
                data.filter['trainingLevel'] = this.trainingLevel
            }
            const dicResp = await queryDic(data)
            if (dicResp.code == 200 && dicResp.data) {
                let keyword = '其他'
                for (const key in dicResp.data) {
                    let items = []
                    let obj = dicResp.data[key]
                    for (const objKey in obj) {
                        items.push({
                            value: objKey,
                            label: obj[objKey]
                        })
                    }
                    items = _.sortBy(items, ['value'])
                    items = items
                        .filter(o => o.label.indexOf(keyword) == -1)
                        .concat(items.filter(o => o.label.indexOf(keyword) != -1))
                    _this.$set(_this.options, key, items)
                }
                this.citys = getCitys(this.options)
            }
        },
        // 修改当前年级
        changeCurrentGrade(val) {
            this.currentGrade = val
            // 本科生逻辑：培养专业与学籍专业的数据与当前年级有关
            if (this.userInfo.currentManageDptId === '1') {
                // 最新的当前年级赋值
                this.currentGrade = val
                this.getDictionaryData()
                // 当前年级修改后清空学籍专业(ID-68-STATUS_PROFESSION_)和培养专业(ID-69-CULTURE_PROFESSION_)
                this.commonInfo.forEach(value => {
                    // 学籍信息表的联动关系
                    if (value.tableName === 'student_status_information_t') {
                        if (value.formInfo['ID-68-STATUS_PROFESSION_']) {
                            value.formInfo['ID-68-STATUS_PROFESSION_'].columnValue = null
                        }
                        if (value.formInfo['ID-69-CULTURE_PROFESSION_']) {
                            value.formInfo['ID-69-CULTURE_PROFESSION_'].columnValue = null
                        }
                    }
                })
                // 根据改变的当前年级，重新获取学籍专业下拉框的数据，前提是当年年级和学籍学院都有值，其中一个没有值则清空学籍专业下拉框
                this.getStuStatusProfession(this.currentGrade, this.universityCollege)
            }
        },
        // 根据类型以及字段名填入对应的值
        // fieldObj字段对象，dicKey字典key，domType为dom类型，keyName为表中所对应的字段名
        getValue(fieldObj) {
            // 下拉框
            if (fieldObj.type === 'select') {
                if (fieldObj.value === 'G_XZQY') { // 籍贯、详细区域
                    return this.getCityName(fieldObj.columnValue)
                } else if (fieldObj.value === 'G_GJQU') { // 国家地区
                    return this.getTextByGJDQ(fieldObj.columnValue, this.options.G_GJQU)
                } else if (fieldObj.fieldId === 70) { // 专业方向名称
                    return this.getTextByGJDQ(fieldObj.columnValue, this.ZYFXMCOptions)
                } else {
                    return this.getTextByValue(fieldObj)
                }
            }
            // 日期
            if (fieldObj.type === 'date') {
                return this.getFormatDate(fieldObj.columnValue)
            }
            return fieldObj.columnValue
        },
        // 获取城市
        getCityName(val) {
            return getCityNameByValue(val, this.citys)
        },
        // 当地点columnValue为三位数
        getTextByGJDQ(val, array) {
            if (val == null) {
                return null;
            }
            if (!array) {
                return null;
            }
            let option = array.find(_ => _.value == val);
            return option ? option.label : null;
        },
        // 根据value值获取label值
        getLabelByValue(array, columnValue) {
            if (columnValue === null || columnValue === '') {
                return columnValue
            }
            let option = array.find(
                c => c.value == columnValue
            )
            if (option) {
                return option.label
            } else {
                // 如果没有匹配项取columnValue
                return columnValue
            }
        },
        // 根据value拼接label(value)
        spliceLabelValue(array, columnValue) {
            if (columnValue === null || columnValue === '') {
                return columnValue
            }
            let option = array.find(
                c => c.value == columnValue
            )
            if (option) {
                return option.label + '(' + columnValue + ')'
            } else {
                // 如果没有匹配项取columnValue
                return columnValue
            }

        },
        // 根据label值获取value值
        getValueByLabel(array, columnValue) {
            if (columnValue === null || columnValue === '') {
                return columnValue
            }
            let option = array.find(
                c => c.label == columnValue
            )
            if (option) {
                return option.value
            } else {
                // 如果没有匹配项取columnValue
                return null
            }
        },
        // 下拉框数据处理
        getTextByValue(column) {
            // 正常字典逻辑
            if (column.fieldId === 68 && column.columnValue) { // 学籍专业由于不获取字典,获取接口拿数据,故此处逻辑另外编写
                if (this.XJZYOptions.length > 0) {
                    return this.getLabelByValue(this.XJZYOptions, column.columnValue)
                } else {
                    return column.columnValue
                }
            } else if (column.fieldId === 166) { // 对方院校、院所数据回填
                if (column.columnValue && this.unionCollegeData.length > 0) {
                    return this.getLabelByValue(this.unionCollegeData, column.columnValue)
                }
            } else if (column.value != null && this.options.hasOwnProperty(column.value)) {
                if(column.fieldId === 69) { // 培养专业要求回显 label(value)形式
                    return this.spliceLabelValue(this.options[column.value], column.columnValue)
                } else {
                    return this.getLabelByValue(this.options[column.value], column.columnValue)
                }
                
            }
        },
        // 处理日期格式
        getFormatDate(val) {
            return val ? moment(val).format('YYYY-MM-DD') : null
        },
        // 新增表单
        addForm() {
            let currentTable = _.cloneDeep(this.commonInfoCopy[0])
            currentTable.id = ADD_FORM
            currentTable.operType = null
            currentTable.originData.forEach(originVal => {
                originVal.columnValue = null
                originVal.oldColumnValue = null
                originVal.newRealValue = null
                originVal.oldRealValue = null
            })
            currentTable.tableData.forEach(tableVal => {
                tableVal.columnValue = null
                tableVal.oldColumnValue = null
                tableVal.newRealValue = null
                tableVal.oldRealValue = null
            })
            for (let formKey in currentTable.formInfo) {
                // 新增时索引赋值
                currentTable.formInfo[formKey]['currentIndex'] = this.commonInfo.length > 0 ? this.commonInfo.length : 0
                currentTable.formInfo[formKey].columnValue = null
                currentTable.formInfo[formKey].oldColumnValue = null
                currentTable.formInfo[formKey].newRealValue = null
                currentTable.formInfo[formKey].oldRealValue = null
            }
            this.commonInfo.push(currentTable)
        },
        // 删除表单
        deleteTable(index, id) {
            this.$confirm("是否刪除该行?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(() => {
                // 若删除的是数据库的数据需将此数据保存到提交的传参中
                if (typeof(id) === 'number') {
                    let currentDeleteForm = _.cloneDeep(this.commonInfo[index].formInfo)
                    let currentDeleteArr = []
                    for (let key in currentDeleteForm) {
                        currentDeleteForm[key].oldColumnValue = currentDeleteForm[key].columnValue
                        currentDeleteForm[key].columnValue = null
                        currentDeleteArr.push(currentDeleteForm[key])
                    }
                    this.deleteStuDetailInfoList.push({
                        id: id,
                        operType: FORM_TYPE.DELETE,
                        stuAttriInfos: currentDeleteArr
                    })
                }
                this.commonInfo.splice(index, 1)
                // 删除时索引重新赋值
                this.commonInfo.forEach((value, index) => {
                    for (let key in value.formInfo) {
                        value.formInfo[key].currentIndex = index
                    }
                })
            })
        },
        // 有审核字段提交
        hasCheckFieldSubmit(fileList, modifyDesc) {
            let postData = _.cloneDeep(this.postData)
            // 处理导师1、导师2的传参
            postData.stuDetailInfoList.forEach(value => {
                value.stuAttriInfos.forEach(item => {
                    // 处理导师1或者导师2
                    if (item.fieldId === 77 || item.fieldId === 78 && item.columnValue) {
                        item.columnValue = item.columnValue.match(/\((\S*)\)/)[1] ? item.columnValue.match(/\((\S*)\)/)[1] : item.columnValue
                    }
                })
            })
            // 删除major_name
            this.postData.stuDetailInfoList.forEach(value => {
                // 单独处理为输入框时的学位专业的未修改前的值
                let majorCodeObj = value.stuAttriInfos.find(item => ((item.fieldId === 146 || item.fieldId === 219 || item.fieldId === 233) && item.column === 'MAJOR_CODE_'));
                let majorNameObj = value.stuAttriInfos.find(item => ((item.fieldId === 146 || item.fieldId === 219 || item.fieldId === 233) && item.column === 'MAJOR_NAME_'));
                if (majorCodeObj) {
                    majorCodeObj.oldColumnValue = majorNameObj.oldRecord
                    majorCodeObj.columnValue = majorCodeObj.chooseType === 'input' ? majorCodeObj.columnValue : majorCodeObj.newRealValue
                    let deleteIndex = value.stuAttriInfos.findIndex(item => ((item.fieldId === 146 || item.fieldId === 219 || item.fieldId === 233) && item.column === 'MAJOR_NAME_'));
                    if (deleteIndex >= 0) {
                        value.stuAttriInfos.splice(deleteIndex, 1)
                    }
                }
            })
            submitField(
                this.uid,
                fileList,
                modifyDesc,
                postData,
                this.dataSource,
                () => {
                    this.$refs.diffDialog.close();
                    this.$message({
                        type: "success",
                        message: this.$t("message.saveSuccess")
                    });
                    setTimeout(() => {
                        this.getStuDetail()
                    }, 500)
                }
            )
        },
        // 无审核字段提交
        hasNotCheckFieldSubmit() {
            let postData = _.cloneDeep(this.postData)
            // 处理导师1、导师2的传参
            postData.stuDetailInfoList.forEach(value => {
                value.stuAttriInfos.forEach(item => {
                    // 处理导师1或者导师2
                    if ((item.fieldId === 77 || item.fieldId === 78) && item.columnValue) {
                        item.columnValue = item.columnValue.match(/\((\S*)\)/)[1] ? item.columnValue.match(/\((\S*)\)/)[1] : item.columnValue
                    }
                    if ((item.fieldId === 146 || item.fieldId === 219 || item.fieldId === 233) && item.columnValue) {
                        // 输入框,major_code和major_name的columnValue均存入'000000',newRealValue存入输入框输入的值
                        if (item.column === 'MAJOR_CODE_') {
                            item.newRealValue = item.chooseType === 'input' ? item.columnValue : item.newRealValue
                            item.columnValue = item.chooseType === 'input' ? '000000' : item.columnValue
                        }
                        if (item.column === 'MAJOR_NAME_') {
                            item.newRealValue = item.chooseType === 'input' ? item.columnValue : item.newRealValue
                            item.columnValue = item.newRealValue
                        }
                    }
                })
            })
            // 删除major_name
            this.postData.stuDetailInfoList.forEach(value => {
                // 单独处理为输入框时的学位专业的未修改前的值
                let majorCodeObj = value.stuAttriInfos.find(item => ((item.fieldId === 146 || item.fieldId === 219 || item.fieldId === 233) && item.column === 'MAJOR_CODE_'));
                let majorNameObj = value.stuAttriInfos.find(item => ((item.fieldId === 146 || item.fieldId === 219 || item.fieldId === 233) && item.column === 'MAJOR_NAME_'));
                if (majorCodeObj) {
                    majorCodeObj.oldColumnValue = majorNameObj.oldRecord
                    majorCodeObj.columnValue = majorCodeObj.chooseType === 'input' ? majorCodeObj.columnValue : majorCodeObj.newRealValue
                    let deleteIndex = value.stuAttriInfos.findIndex(item => ((item.fieldId === 146 || item.fieldId === 219 || item.fieldId === 233) && item.column === 'MAJOR_NAME_'));
                    if (deleteIndex >= 0) {
                        value.stuAttriInfos.splice(deleteIndex, 1)
                    }
                }
            })
            stuDetailSubmit(postData).then(res => {
                if (res.code == 200) {
                    this.$refs.diffDialog.open()
                }
            })
        },
        saveData() {
            let _this = this
            // 所有需要校验的表格合集
            let validateFields = []
            this.commonInfo.forEach((commonInfo, index) => {
                validateFields.push('formInfo' + index)
            })
            Promise.all(validateFields.map(item => {
                return new Promise((resolve, reject) => {
                    _this.$refs[item][0].validate((valid) => {
                        if (valid) {
                            resolve(valid)
                        } else {
                            setTimeout(() => {
                                let isError = document.getElementsByClassName("is-error")
                                if (isError[0] && isError[0] && isError[0].querySelector('input')) {
                                    isError[0].querySelector('input').focus()
                                }
                            }, 1)
                            reject()
                        }
                    })
                })
            })).then(res => {
                // 所有表格校验通过
                this.postData.stuDetailInfoList = []
                // 存入差异数据
                let currentData = _.cloneDeep(this.commonInfo)
                currentData.forEach((value, index) => {
                    value.stuAttriInfos = []
                    for (let key in value.formInfo) {
                        // 表名一致
                        if (value.tableName !== value.formInfo[key].from) {
                            break
                        }
                        if (value.formInfo[key].originValue === null && value.formInfo[key].columnValue === '') {
                            value.formInfo[key].columnValue = null
                        }
                        // 已修改内容
                        if (value.formInfo[key].columnValue !== value.formInfo[key].originValue) {
                            // 处理下拉框的label值赋值
                            if (value.formInfo[key].isEdit && value.formInfo[key].type === "select" && value.formInfo[key].value) {
                                // 学籍专业，学籍专业的下拉框数据由接口获取
                                if (value.formInfo[key].fieldId === 68 && _this.XJZYOptions.length > 0) {
                                    value.formInfo[key].newRealValue = _this.getLabelByValue(_this.XJZYOptions, value.formInfo[key].columnValue).split('(')[0]
                                } else {
                                    value.formInfo[key].newRealValue = _this.getLabelByValue(_this.options[value.formInfo[key].value], value.formInfo[key].columnValue)
                                    value.formInfo[key].oldRealValue = _this.getLabelByValue(_this.options[value.formInfo[key].value], value.formInfo[key].oldColumnValue)
                                }
                            }
                            // 单独处理专业方向名称
                            if (value.formInfo[key].isEdit && value.formInfo[key].type === "select" && value.formInfo[key].fieldId === 70 && _this.ZYFXMCOptions.length > 0) {
                                value.formInfo[key].newRealValue = _this.getLabelByValue(_this.ZYFXMCOptions, value.formInfo[key].columnValue)
                                value.formInfo[key].oldRealValue = _this.getLabelByValue(_this.ZYFXMCOptions, value.formInfo[key].oldColumnValue)
                            }
                            // 处理教育背景学位专业/硕士学位专业/博士学位专业
                            // 兼容老数据，老数据的专业不存在于国标的字典中
                            if (value.formInfo[key].fieldId === 146 || value.formInfo[key].fieldId === 219 || value.formInfo[key].fieldId === 233) {
                                value.formInfo['ID-' + value.formInfo[key].fieldId + '-MAJOR_NAME_'].chooseType = value.formInfo[key].chooseType
                                value.formInfo['ID-' + value.formInfo[key].fieldId + '-MAJOR_NAME_'].columnValue = value.formInfo[key].columnValue
                                value.formInfo['ID-' + value.formInfo[key].fieldId + '-MAJOR_NAME_'].newRealValue = value.formInfo[key].newRealValue
                            }
                            // 处理其他，护照有校日期止的传参
                            if (key === 'ID-200-PASSPORT_EXPIRE_' && value.formInfo[key].columnValue) {
                                value.formInfo[key].columnValue = new Date(value.formInfo[key].columnValue).getTime()
                            }
                            // 记录oldColumnValue
                            value.formInfo[key].oldColumnValue = value.formInfo[key].oldRecord
                            // 教务员可编辑模式下 需要把isEdit参数 置为2 传给后端
                            if(this.superLimit && !this.isStudent) {
                                value.formInfo[key].isEdit = 2
                            }
                            value.stuAttriInfos.push(value.formInfo[key])
                        }
                    }
                    if (value.stuAttriInfos.length > 0) {
                        // 新增
                        if (parseInt(value.id) === 0 && !value.operType) {
                            value.id = null
                            value.operType = 1
                        } else if (typeof(value.id) === 'number' && parseInt(value.id) !== 0 && !value.operType) { // 编辑
                            value.operType = 2
                        }
                        _this.postData.stuDetailInfoList.push({
                            id: value.id,
                            operType: value.operType,
                            stuAttriInfos: value.stuAttriInfos
                        })
                    }
                })
                // 合入删除表单的数据
                this.postData.stuDetailInfoList = this.postData.stuDetailInfoList.concat(this.deleteStuDetailInfoList)
                if (this.postData.stuDetailInfoList.length === 0) {
                    this.$message("内容未修改，无需保存")
                    return
                }
                this.$confirm("您确定要提交吗?", "提示", {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    type: "warning"
                }).then(() => {
                    // 有审核数据提交
                    // console.log(this.postData)
                    if (this.checked) {
                        this.$refs.diffDialog.open()
                    } else { // 无审核数据提交
                        _this.hasNotCheckFieldSubmit() 
                    }
                })
            }).catch(e => {
                // 校验不通过
            })
        }
    },
    watch: {
    }
};
</script>
<style lang="scss" scoped>
.common-info-new-container ::v-deep {
    // margin-top: 10px;
    .change-tip {
        line-height: 32px;
        font-size: 16px;
        float: left;
        margin-left: 15px;
        .color-block {
            background: #ff7800;
            display: inline-block;
            width: 25px;
            height: 12px;
            margin: 0 5px 0 0;
        }
    }
    .field-checked {
        font-weight: bold;
        color: #ff7800;
    }
    .common-info-form {
        padding-bottom: 7px;
        .el-form-item {
            // margin-bottom: 13px!important;
            margin-bottom: 0!important;
        }
    }
    .common-info-new-content {
        position: relative;
        table {
            width: 100%;
            border-collapse: collapse;
            .is-require {
                color: #f56c6c;
            }
            td {
                padding: 7px 4px;
                border: 1px solid #e4e7ed;
            }
            .common-info-delete-btn {
                position: absolute;
                right: 5px;
                top: 0px;
                font-size: 14px;
                text-decoration: underline;
                color: #f56c6c;
            }
            .common-info-td-title {
                width: 14.11%;
                text-align: right;
                background: #F5F7F9;
            }
            .common-info-td-content {
                width: 19.22%;
            }
        }
    }
    .add-btn-container {
        margin-top: 24px;
        border: 1px solid #ced6df;
        line-height: 40px;
        text-align: center;
        cursor: pointer;
    }
    .image-container {
        text-align: center;
        div {
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 7px 0;
            span {
                margin-left: 20px;
                .el-icon-delete {
                    display: block;
                }
            }
        }
        img {
            width: 148px;
            height: 148px;
        }
        i {
            font-size: 16px;
            cursor: pointer;
            z-index: 99999;
        }
    }
    .preview-dialog ::v-deep {
        .el-dialog__body {
            text-align: center;
            padding: 7px 10px;
            img {
                width: auto;
            }
        }
    }
}
</style>